package com.wang.system.manager;

import com.wang.common.core.constants.CacheConstants;
import com.wang.common.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class QuestionCacheManager {

    @Autowired
    private RedisService redisService;

    /**
     * 把题目id存入redis的list中
     * @param questionId 题目id
     */
    public void addCache(Long questionId){
        //key-->question:list ; value--> questionId
        //leftPush: 新增的题目添加到左边
        redisService.leftPushForList(CacheConstants.QUESTION_LIST,questionId);
    }

    /**
     * 把题目id从redis的list中删掉
     * @param questionId 题目id
     */
    public void deleteCache(Long questionId){
        redisService.removeForList(CacheConstants.QUESTION_LIST,questionId);
    }

}
